/*
 * Copyright 2013 floreysoft GmbH (www.floreysoft.net)
 *
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package com.floreysoft.gwt.drive.client.realtime;

import com.floreysoft.gwt.drive.client.callback.ErrorCallback;
import com.floreysoft.gwt.drive.client.callback.ModelCallback;
import com.floreysoft.gwt.drive.client.callback.RealtimeCallback;

/**
 * Holds the static Methods to load realtime files  
 *
 */
public final class Realtime {

	
	protected Realtime(){
		
	}
	
	/**
	 * Loads a realtime file
	 * @param docId the fileId
	 * @param onLoaded Callback thats called when the file got loaded
	 */
	public static native void load(String docId, RealtimeCallback onLoaded)/*-{
		$wnd.gapi.drive.realtime.laod(docId,function(document){
			onLoaded.@com.floreysoft.gwt.drive.client.callback.RealtimeCallback::onLoaded(Lcom/floreysoft/gwt/drive/client/realtime/Document;)(document);
		});
	}-*/;
	
	
	/**
	 * Loads a realtime file
	 * @param docId the fileId
	 * @param onLoaded  Callback with the {@link Document} thats called when the file got loaded
	 * @param initializeModel Callback with the {@link Model} thats called when the file got loaded
	 */
	public static native void load(String docId, RealtimeCallback onLoaded, ModelCallback initializeModel)/*-{
		$wnd.gapi.drive.realtime.load(docId,function(document){
			onLoaded.@com.floreysoft.gwt.drive.client.callback.RealtimeCallback::onLoaded(Lcom/floreysoft/gwt/drive/client/realtime/Document;)(document);
		},function(model){
			initializeModel.@com.floreysoft.gwt.drive.client.callback.ModelCallback::initializeModel(Lcom/floreysoft/gwt/drive/client/realtime/Model;)(model);
		});
	}-*/;

	
	/**
	 * Loads a realtime file
	 * @param docId the fileId
	 * @param onLoaded  Callback with the {@link Document} thats called when the file got loaded
	 * @param initializeModel Callback with the {@link Model} thats called when the file got loaded
	 * @param errorCallback Callback with the {@link Error} thats called when an error occurs
	 */
	public static native void load(String docId, RealtimeCallback onLoaded, ModelCallback initializeModel, ErrorCallback errorCallback)/*-{
		$wnd.gapi.drive.realtime.load(docId,function(document){
			onLoaded.@com.floreysoft.gwt.drive.client.callback.RealtimeCallback::onLoaded(Lcom/floreysoft/gwt/drive/client/realtime/Document;)(document);
		},function(model){
			initializeModel.@com.floreysoft.gwt.drive.client.callback.ModelCallback::initializeModel(Lcom/floreysoft/gwt/drive/client/realtime/Model;)(model);
		},function(error){
			errorCallback.@com.floreysoft.gwt.drive.client.callback.ErrorCallback::onError(Lcom/floreysoft/gwt/drive/client/realtime/Error;)(error);
		});
	}-*/;
}
